package net.jlibrary.invoice.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.BatchSize;

import net.jlibrary.common.core.annotation.CodeGenComment;
import net.jlibrary.common.core.annotation.SearchCondition;
import net.jlibrary.common.core.annotation.SearchField;
import net.jlibrary.common.core.entity.BaseObject;
import net.jlibrary.common.project.domain.Group;

@Entity(name = "tab_electronic_invoice")
//@SeePurview(value = "group.globalPath")
@CodeGenComment(value = "销方企业信息", genSelect = false)
@BatchSize(size = 15)
public class ElectronicInvoice extends BaseObject {
	private static final long serialVersionUID = 5244876929035840349L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@SearchField(value = "id", condition = SearchCondition.EQUAL)
	private Long id;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "group_id")
	@SearchField(value = "group", condition = SearchCondition.EQUAL)
	@CodeGenComment(value = "企业")
	private Group group;

	@Column(length = 20)
	@CodeGenComment(value = "开户行名称", viewList = true, required = true)
	private String bankName;// 开户行名称

	@Column(length = 50)
	@CodeGenComment(value = "开户行账号", viewList = true, required = true)
	private String bankAccount;// 开户行账号

	@Column(length = 25)
	@SearchField(value = "nsrsbh", condition = SearchCondition.EQUAL)
	@CodeGenComment(value = "纳税人识别号", viewList = true, required = true)
	private String nsrsbh;// 纳税人识别号

	@Column(length = 100)
	@CodeGenComment(value = "公司详细地址", viewList = true, required = true)
	private String address;// 公司详细地址

	@Column(length = 30)
	@CodeGenComment(value = "联系电话", viewList = true, required = true)
	private String phone;// 联系电话

	@Column(length = 40)
	@CodeGenComment(value = "邮箱", viewList = true, required = true)
	private String email;// 邮箱

	@Column(length = 30)
	@CodeGenComment(value = "开票人", viewList = true, required = true)
	private String biller;// 开票人

	@Column(length = 30)
	@CodeGenComment(value = "收款人", viewList = true, required = true)
	private String payee;// 收款人

	@Column(length = 30)
	@CodeGenComment(value = "复核人", viewList = true, required = true)
	private String reviewer;// 复核人

	@Column(updatable = false)
	@Temporal(TemporalType.TIMESTAMP)
	@CodeGenComment(value = "创建时间", viewList = true)

	private Date createdate;
	@Temporal(TemporalType.TIMESTAMP)
	private Date lastdate;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Group getGroup() {
		return group;
	}

	public void setGroup(Group group) {
		this.group = group;
	}

	public String getBankName() {
		return bankName;
	}

	public void setBankName(String bankName) {
		this.bankName = bankName;
	}

	public String getBankAccount() {
		return bankAccount;
	}

	public void setBankAccount(String bankAccount) {
		this.bankAccount = bankAccount;
	}

	public String getNsrsbh() {
		return nsrsbh;
	}

	public void setNsrsbh(String nsrsbh) {
		this.nsrsbh = nsrsbh;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getBiller() {
		return biller;
	}

	public void setBiller(String biller) {
		this.biller = biller;
	}

	public String getPayee() {
		return payee;
	}

	public void setPayee(String payee) {
		this.payee = payee;
	}

	public String getReviewer() {
		return reviewer;
	}

	public void setReviewer(String reviewer) {
		this.reviewer = reviewer;
	}

	public Date getCreatedate() {
		return createdate;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public void setCreatedate(Date createdate) {
		this.createdate = createdate;
	}

	public Date getLastdate() {
		return lastdate;
	}

	public void setLastdate(Date lastdate) {
		this.lastdate = lastdate;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ElectronicInvoice other = (ElectronicInvoice) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	@Override
	public Serializable getPrimaryKey() {
		return id;
	}

	@Override
	public String toString() {
		return "ElectronicInvoice [id=" + id + ", group=" + group + ", bankName=" + bankName + ", bankAccount="
				+ bankAccount + ", nsrsbh=" + nsrsbh + ", address=" + address + ", phone=" + phone + ", email=" + email
				+ ", biller=" + biller + ", payee=" + payee + ", reviewer=" + reviewer + ", createdate=" + createdate
				+ ", lastdate=" + lastdate + "]";
	}

}
